package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.StudentTracking;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IStudentTrackingService;
import cn.wolfcode.crm.util.JSONResult;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("studentTracking")
public class StudentTrackingController {

    @Autowired
    private IStudentTrackingService studentTracking;

    @RequestMapping("list")
    @ResponseBody
    public List<StudentTracking> list() {
        return studentTracking.selectAll();
    }

    @RequestMapping("view")
    public String query(QueryObject qo) {
        return "studentTracking";
    }

    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StudentTracking student) {
        JSONResult result = new JSONResult();
        try {
            studentTracking.saveOrUpdate(student);
        } catch (Exception e) {
            result.remark("保存失败");
            e.printStackTrace();
        }
        return result;
    }
    
    @RequestMapping("query")
    @ResponseBody
    public PageResult student(QueryObject qo) {
        return studentTracking.query(qo);
    }

    //回显操作
    @RequestMapping("selectByStudentTrackingId")
    @ResponseBody
    public Object getStudentTracking(Long id){
        return studentTracking.selectByPrimaryKey(id);
    }

    @RequestMapping("audit")
    @ResponseBody
    public Object audit(String auditExplain,Long id){
        JSONResult result = new JSONResult();
        try {
            studentTracking.audit(auditExplain,id);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            return result.remark("审核失败");
        }
    }
    
}
